﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace LunchRoller
{
    public partial class ImportExport : PhoneApplicationPage
    {
        public ImportExport()
        {
            InitializeComponent();
            this.DataContext = App.ViewModel;
            App.BindCommand(App.ViewModel.ExportDataCommand, ApplicationBar.Buttons[0] as ApplicationBarIconButton,()=>(this._lsFormat.Items[_lsFormat.SelectedIndex] as ListPickerItem).Content.ToString());
            App.BindCommand(App.ViewModel.ImportDataCommand, ApplicationBar.Buttons[1] as ApplicationBarIconButton, () => (this._lsFormat.Items[_lsFormat.SelectedIndex] as ListPickerItem).Content.ToString());
            App.BindCommand(App.ViewModel.MailDataCommand, ApplicationBar.Buttons[2] as ApplicationBarIconButton);
            (ApplicationBar.Buttons[3] as ApplicationBarIconButton).Click += new EventHandler(SelectAll_Click);
            
            
        }

        void SelectAll_Click(object sender, EventArgs e)
        {
            _tbImportExport.SelectionStart = 0;
            _tbImportExport.SelectionLength = _tbImportExport.Text.Length;
            _tbImportExport.Focus();
        }

   
    }
}